home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 June / PersonalComputerWorld-June2009-CoverdiscCD.iso / Software / Freeware / Firebug 1.3.3 / firebug-1.3.3-fx.xpi / content / firebug / permissionsOverlay.js < prev    next >
Encoding:
JavaScript  |  2009-02-19  |  2.2 KB  |  72 lines

  1. /* See license.txt for terms of usage */
  2.  
  3. var firebugPermissionsOverlay = {};
  4.  
  5. (function() { with (XPCOMUtils) {
  6.  
  7. // ************************************************************************************************
  8. // Constants
  9.  
  10. const localeService = CCSV("@mozilla.org/intl/nslocaleservice;1", "nsILocaleService");
  11. const bundleService = CCSV("@mozilla.org/intl/stringbundle;1", "nsIStringBundleService");
  12. const appLocale = localeService.getApplicationLocale();
  13. const stringBundle = bundleService.createBundle("chrome://firebug/locale/firebug.properties", appLocale);
  14.  
  15. // ************************************************************************************************
  16. // Implementation
  17.  
  18. this.onLoad = function()
  19. {
  20.     // Change buttons labels
  21.     document.getElementById("btnBlock").label = this.getString("panel.Disable");
  22.     document.getElementById("btnAllow").label = this.getString("panel.Enable");
  23. };
  24.  
  25. this.getCapabilityString = function(aCapability)
  26. {
  27.     var self = firebugPermissionsOverlay;
  28.  
  29.     var stringKey = null;
  30.     switch (aCapability) 
  31.     {
  32.         case nsIPermissionManager.ALLOW_ACTION:
  33.           stringKey = "panel.Enabled";
  34.           break;
  35.  
  36.         case nsIPermissionManager.DENY_ACTION:
  37.           stringKey = "panel.Disabled";
  38.           break;
  39.  
  40.         default:
  41.             return self._getCapabilityString.call(gPermissionManager, aCapability);
  42.     }
  43.  
  44.     return self.getString(stringKey);
  45. };
  46.  
  47. this.getString = function(stringName)
  48. {
  49.     return stringBundle.GetStringFromName(stringName);
  50. };
  51.  
  52. // ************************************************************************************************
  53.  
  54. }}).apply(firebugPermissionsOverlay);
  55.  
  56. // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  57.  
  58. /**
  59.  * Provide custom string for permission status. 
  60.  * (Allow|Block) -> (Enabled|Disabled)
  61.  */
  62. firebugPermissionsOverlay._getCapabilityString = gPermissionManager._getCapabilityString;
  63. gPermissionManager._getCapabilityString = firebugPermissionsOverlay.getCapabilityString;
  64.  
  65. /**
  66.  * Register event handler in order to control overlay's life cycle.
  67.  */
  68. window.addEventListener("load", function() {
  69.     firebugPermissionsOverlay.onLoad();
  70. }, false);
  71.  
  72.